package cn.schoolwow.quickdao.test.module.business.user.dml.menu.flow;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.test.entity.Menu;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import org.junit.Assert;

import java.util.ArrayList;
import java.util.List;

public class FirstInsertInsertMenuFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);

        List<Menu> menuList = new ArrayList<>();
        {
            Menu menu = new Menu();
            menu.setMenuName("用户管理");
            menu.setUrl("/user");
            menuList.add(menu);
        }
        {
            Menu menu = new Menu();
            menu.setMenuName("角色管理");
            menu.setUrl("/role");
            menuList.add(menu);
        }
        {
            Menu menu = new Menu();
            menu.setMenuName("部门管理");
            menu.setUrl("/department");
            menuList.add(menu);
        }
        int effect = dao.insertIgnore(menuList);
        Assert.assertEquals(menuList.size(), effect);
    }

    @Override
    public String name() {
        return "第一次插入菜单信息";
    }
}
